<script setup lang="ts">
import { ref, computed } from 'vue'

const showPopover = ref(false)
// 接收父组件 值
const props = defineProps<{
  disabled?: boolean
}>()
// 发送 事件
const emit = defineEmits<{
  (e: 'on-delete'): void
  (e: 'on-preview'): void
}>()
const actions = computed(() => {
  return [{ text: '查看处方', disabled: props.disabled }, { text: '删除订单' }]
})
const onSelect = (action: { text: string }, index: number) => {
  // 负责通知父组件,具体操作由父组件执行
  if (index === 0) {
    emit('on-preview')
  }
  if (index === 1) {
    emit('on-delete')
  }
}
</script>

<template>
  <div class="cp-consult-more">
    <van-popover
      v-model:show="showPopover"
      :actions="actions"
      @select="onSelect"
      placement="top-start"
    >
      <template #reference> 更多 </template>
    </van-popover>
  </div>
</template>

<style lang="scss" scoped>
.cp-consult-more {
  color: var(--cp-tag);
  flex: 1;
  font-size: 13px;
}
</style>
